23 template <class T
> string
toStr(const T
&x
){ stringstream s
; s
<< x
; return s
.str(); }
24 template <class T
> int toInt(const T
&x
){ stringstream s
; s
<< x
; int r
; s
>> r
; return r
; }
26 #define For(i, a, b) for (int i=(a); i<(b); ++i)
27 #define foreach(x, v) for (typeof (v).begin() x = (v).begin(); x != (v).end(); ++x)
28 #define D(x) cout << #x " is " << x << endl
35 for (int C
=1; C
<=casos
; ++C
){
36 cout
<< "Case " << C
<< ": ";
37 int rows
, cols
, important
, notimportant
;
38 cin
>> rows
>> cols
>> important
>> notimportant
;
47 vector
<pair
<int, char> > v
;
49 v
.push_back(make_pair(p
->second
, p
->first
));
51 sort(v
.rbegin(), v
.rend());
53 for (int i
=0; i
<v
.size(); ++i
){
54 if (v
[i
].first
== v
[0].first
) ans
+= v
[i
].first
* important
;
55 else ans
+= v
[i
].first
* notimportant
;